import argparse
import spacy

nlp = spacy.load("en_core_web_sm")

def split_text(text):
    doc = nlp(text)
    tokenS = []
    for sent in doc.sents:
        for token in sent:
            if not token.is_punct or token.text == "'":
                tokenS.append(token.text)
            else:
                if len(tokenS) > 0:
                    yield " ".join(tokenS)
                    tokenS = []
        if len(tokenS) > 0:
            yield " ".join(tokenS)
            tokenS = []
    if len(tokenS) > 0:
        yield " ".join(tokenS)


parser = argparse.ArgumentParser()
parser.add_argument("file_path", help="path to input file")
args = parser.parse_args()

with open(args.file_path, "r") as f:
    text = f.read()

splited_text = split_text(text)

for clause in splited_text:
    for i in range(0, len(clause), 40):
        print(f"{clause[i:i+40]}")
